<template>
  <el-table
    :data="tableData.filter(data => !search || data.name.toLowerCase().includes(search.toLowerCase()))"
    style="width: 94%">
    <el-table-column label="商品编号(条码)" prop="date"/>
    <el-table-column label="商品名称" prop="name"/>
    <el-table-column label="所属分类" prop="type"/>
    <el-table-column label="折扣" prop="discount"/>
    <el-table-column label="会员折扣" prop="vipDiscount"/>
    <el-table-column label="库存剩余" prop="inventory"/>
    <el-table-column align="center">
      <template slot="header" slot-scope="scope">
        <el-input v-model="search" size="mini" placeholder="输入商品关键字搜索"/>
      </template>
      <template slot-scope="scope">
        <el-button size="mini" type="success" @click="handleEdit(scope.$index, scope.row)">重新上架
        </el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
  export default {
    name: "OffShelf",
    data() {
      return {
        tableData: [
          {
            date: '6925635621465',
            name: '人民公社',
            type: '食品',
            discount: '0.9',
            vipDiscount: '0.85',
            inventory: '150'
          },
          {
            date: '6970628617253',
            name: '手剥巴旦木',
            type: '食品',
            discount: '0.9',
            vipDiscount: '0.85',
            inventory: '410'
          }
        ],
        search: ''
      }
    },
    methods: {
      handleEdit(index, row) {
        console.log(index, row);
      },
      handleDelete(index, row) {
        console.log(index, row);
      }
    },
  }
</script>

